#include "RSA_Breaker.h"
#include <iostream>
#include <vector>
using namespace std;
const int MAX_SIZE = 1e7+30;

vector<bool> isNotPrime(MAX_SIZE, false);
vector<int> prime;

void makePrime(){
    isNotPrime[0] = 1;
    isNotPrime[1] = 1;
    for(int i = 2; i <= MAX_SIZE; ++i){
        if(isNotPrime[i] == false){
            prime.push_back(i);
        }
        for(int p : prime){
            if(p * i >= MAX_SIZE){
                break;
            }
            isNotPrime[p*i] = 1;
            if(i % p == 0){
                break;
            }
        }
    }
}

signed main(){
    makePrime();

    int base_num = 8;
    int itr = 0;
    for(int i = 20; i <=5e4; i *= base_num){
        while(prime[itr] < i){
            itr ++;
        }
        int p = prime[itr];
        itr ++;
        int q = prime[itr];
        printf("Breaking: %d\n", p*q);
        int time = 0;
        RSA rsa = RSA_Breaker(p*q, time);
        printf("finished breaking: d = %d\n", rsa.d());
        printf("Culculate Time: %d\n", time);
    }
    return 0;
}
